<?php 
	$q = Doctrine_Query::create()
    ->select('a.id, a.description')
    ->from('sfMenuTitle a')
    ->andWhere ('a.backoffice=1')
    ->orderBy('a.xorder')    ;
	$options = $q->execute();
//echo $q->getSql();	
?>
<div id="menu_top" >
<ul id="menu">
  <?php	foreach($options as $menu):?>
	<li><?php echo link_to($menu->description, '@homepage') ?>
		<ul>
			<?php $ssmenu = Doctrine_Query::create()
    			->select('u.name, u.description')
			    ->from('sfMenuModule u')
			    ->andWhere ("u.title_id='". $menu->id."'")
			    ->andWhere ('u.backoffice=1')
			    ->orderBy('u.xorder')    
			    ->execute();
			 ?>
  			<?php	foreach($ssmenu as $sousmenu):?>
  				<?php if($sousmenu->name=='display'){
  					$nameSM = $sousmenu->name;
  					echo '<li>'.link_to($sousmenu->description, $nameSM.'/index?className='.$sousmenu->className) . '</li>';
  				}else{
  					$nameSM = $sousmenu->name;
  					echo '<li>'.link_to($sousmenu->description, $nameSM.'/index') . '</li>';
  				}?>
				
 			 <?php endforeach;?>
		</ul>
	</li>	
  <?php endforeach;?>
</ul>
</div>	
<script type="text/javascript">
   initMenu();
</script>
    